import java.util.Scanner;

public class Test {
    public static void main(String[] args){
        int[] array = new int[]{10,20,30,40,50};
        for(int x : array){
            System.out.print(x+" ");
        }
        System.out.printf("\n");
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        while(n != 0) {
           // int n = scanner.nextInt();
            int j = 0, i = 0, p = 0;
            int[] array1 = new int[array.length + 1];
            for (i = 0; i < array.length; i++) {
                if (array[i] <= n) {
                    array1[j] = array[i];
                    j++;
                }
                else {
                    array1[j] = n;
                    j++;
                    p = i;
                    break;
                }
            }
            if(i == array.length){
                array1[j] = n;
            }
            else {
                for (i = p; i < array.length; i++) {
                    array1[j] = array[i];
                    j++;
                }
            }
            for (int x : array1) {
                System.out.print(x + " ");
            }
            System.out.printf("\n");
            n = scanner.nextInt();
        }
    }
}
